#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>

using namespace std;

int main()
{
	printf("%05d\n", 11);
	return 0;
}
#include <iostream>
#include<vector>
using namespace std;

int main()
{
    vector<int> v = { 1,1 };
    for (int i = 2; i < 10001; i++)
    {
        v.push_back((v[i - 1] + v[i - 2] % 10000));
    }
    int n, j;
    while (cin >> n)
    {

        for (int i = 0; i < n; i++)
        {
            cin >> j;
            printf("%04d", v[j]);
        }
        printf("\n");
    }
    return 0;
}

#include<iostream>

using namespace std;
int sum(int s)
{
    int sum = 0;
    while (s != 0)
    {
        sum = sum + s % 10;
        s /= 10;
    }
    return sum;
}
int main()
{
    int ret;
    while (cin >> ret)
    {
        while (ret / 10 > 0)
        {
            ret = sum(ret);
        }
        printf("%d\n", ret);
    }
}